package com.woniu113.junk.site.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniu113.junk.commons.model.Result;
import com.woniu113.junk.site.dto.AllInboundLogDTO;
import com.woniu113.junk.site.dto.InboundLogDTO;
import com.woniu113.junk.site.form.AllInboundLogForm;
import com.woniu113.junk.site.model.InboundLog;
import com.woniu113.junk.site.param.AllInboundLogParam;
import com.woniu113.junk.site.service.InboundLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  入库日志控制器
 * </p>
 *
 * @author 蜡笔没了小新
 * @since 2024年10月16日
 */
@RestController
@RequestMapping("/inboundLog")
@Api(value = "InboundLogController", tags = "入库日志接口")
public class InboundLogController {
    @Resource
    private InboundLogService inboundLogService;

    @PostMapping("/findAll")
    @ApiOperation(value = "查询所有入库日志")
    private Result<List<InboundLogDTO>> findAll(@RequestBody AllInboundLogForm form){
        System.out.println("分页数据1"+form.getPageNum());
        System.out.println("分页数据2"+form.getPageSize());
        // 计算查询的起始索引
        int offset = (form.getPageNum() - 1) * form.getPageSize();
        AllInboundLogDTO dto = inboundLogService.findAll(BeanUtil.toBean(form, AllInboundLogParam.class),offset);
        Integer total = dto.getTotal();
        return Result.getListResult(InboundLogDTO.class).setData(dto.getList()).setMsg("查询所有入库日志成功").setCode(200).setTotal(dto.getTotal());
    }
}

